<?php
require_once("header.php");

if(!$Auth->checkAuth()) // if user isn't logged in
{
    header("location: index.php");
	exit;
}
$uid = $Auth->getLoggedId();
$username = getUserById($uid);
$template->assign('script', 'dashboard');

//News
$nsql = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 4");
if(mysql_num_rows($nsql))
{
    while($nr = mysql_fetch_object($nsql))	
	{
	    $ntitle = stripslashes($nr->title);
		$ndesc = stripslashes($nr->description);	
		if(strlen($ndesc) > 300)
		$ndesc = substr($ndesc, 0, 300)."....";
		$nid = $nr->id;
		$ndate = date('F d, Y', strtotime($nr->date));
		$news[] = array('title' => $ntitle, 'desc' => $ndesc, 'id' => $nid,  'date' => $ndate);
	}
	
	$template->assign('news', $news);
}



$template->display('dashboard.tpl.php');
?>